<?php
session_start();
if (!isset($_SESSION['admin']))
    header('location:index.php');
?>

<!DOCTYPE HTML>
<html>

    <head>
        <title>3D|Didongday 3D- Di động đây</title>
        <?php include('modules/page_head.php'); ?>
    </head>

    <body>
        <div id="main">
            <div id="header">
                <div id="logo">
                    <h1><a href="index.php">Didongde</a></h1>
                    <div class="slogan">Where you can find your own best suitable mobile</div>
                    <?php include_once('modules/logo_header.php'); ?>
                </div>
                <div id="menubar">
                    <?php include_once('modules/menubar.php'); ?>
                </div>
            </div>
            <div id="site_content">
                <div id="sidebar_container">
                    <h2>Tìm kiếm nhanh</h2>
                    <div class="sidebar">
                        <?php
                        include ("modules/quick_search.php");
                        show_manu();
                        ?>
                    </div>
                    <div class="sidebar">
                        <?php show_price(); ?>
                    </div>
                </div>
                <div id="content">
                    <!-- insert the page content here -->
                    <?php
                    include('modules/xulinhapkho.php');
                    //Connect to database, in this case, connect to localhost
                    include_once('conf/dbconfig.php');
                    $cfg = new dbconfig();
                    $host = $cfg->get_dbhost();
                    $db = $cfg->get_dbname();
                    $usr = $cfg->get_dbusername();
                    $pass = $cfg->get_dbpwd();
                    $connection = pg_connect("host = $host dbname = $db user = $usr password = $pass")
                            or die("Cannot connect to database server: " . pg_last_error());
                    ?>
                    <h1>Nhập hàng mới</h1>
                    <div class="form_settings">
                        <form method="post" action="#" enctype="multipart/form-data">
                            <table>
                                <tr><td width="150">Model</td><td width="150">Giá tiền (đơn vị: VNĐ)</td></tr>
                                <tr><td><input type="text" class="search" name="model" accesskey="/" placeholder="Model"/></td>
                                    <td><input type="number" name="price" accesskey="/" placeholder="Giá tiền"/></td></tr>
                                <tr><td>Giá mua</td><td><input type="number" name="gia_mua" accesskey="/" placeholder="Giá mua vào" /></td></tr>
                                <tr><td>Số lượng nhập</td><td><input width="50" type="number" name = "qty" placeholder="Số lượng nhập"/></td><tr>
                                <tr><td colspan="2"></td></tr>
                            </table>
                            <table>
                                <tr><th>Các tính năng khác</th></tr>
                                <tr><td>Nhà sản xuất</td>
                                    <td><select id="id" name="manu" style="width:auto;">
                                            <option value="-1">Chọn nhà sản xuất</option>
                                            <?php
                                            $query_manu = "SELECT distinct name From manufacturer";
                                            $manu_list = pg_query($connection, $query_manu);
                                            $manu_rows = pg_num_rows($manu_list);
                                            for ($i = 0; $i < $manu_rows; $i++) {
                                                $show_manu = pg_fetch_result($manu_list, $i, 'name');
                                                echo "<option value=\"$show_manu\">$show_manu</option>";
                                            }
                                            ?>
                                        </select></td></tr>
                                <tr><td>Bảo hành</td><td><input type="text" class="search" name="warranty"/></td></tr>
                                <tr><td>Khuyến mại</td><td><input type="text" class="search" name="promotion"/></td></tr>
                                <tr><td>Hệ điều hành</td><td><input type="text" class="search" name="os"/></td></tr>
                                <tr><td>Kết nối mạng</td><td><input type="text" class="search" name="network" /></td></tr>
                                <tr><td>Màn hình</td><td><input type="text" class="search" name="screen"/></td></tr>
                                <tr><td>Giải trí</td><td><input type="textarea" class="search" name="entertainment"/> </td></tr>
                                <tr><td>Battery</td><td><input type="text" class="search" name="battery"/> </td></tr>
                                <tr><td>Kiểu dáng</td><td><input type="text" class="search" name="appearance"/></td></tr>
                                <tr><td>Images</td><td><input type="file" name="image"/></td></tr>
                            </table>
                            <table>
                                <tr><td width=60><label for="GPRS">GPRS/EDGE</label></td><td width=60><input type="checkbox" class="checkbox" name="GPRS"/></td>
                                    <td width=60><label for="3G">3G</label></td><td width=60><input type="checkbox" class="checkbox" name="3G"/></td></tr>
                                <tr><td width=60><label for="Wireless">Wireless</label></td><td width=60><input type="checkbox" class="checkbox" name="Wireless"/></td>
                                    <td width=60><label for="bluetooth">Bluetooth</label></td><td width=60><input type="checkbox" class="checkbox" name="bluetooth"/></td></tr>
                            </table>
                            <button title="Gửi thông tin sản phẩm" class="submitIMG" name="submit" type="submit" value="submit" onmouseover="changepic(this)" onmouseout="returnpic(this)" style="margin-left: 40px;"><img class="submitIMG" alt="Nhập hàng" src="style/images/import-button.png"/></button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div id="footer">
            <?php include('modules/footer.php'); ?>
        </div>
    </body>
</html>
